package org.jprobe;

import java.io.IOException;

/**
* Project explorer contract
*
* @author Hussain Al-Mutawa
* @version 1.0
*/
public interface ProjectExplorerInterface<C extends CoverageResultsInterface,T extends JUnitResultsInterface> {
	/**
	 * gets the directories and files listed under the project base directory
	 * @return list of files and directories
	 */
	String[]getFiles();
	/**
	 * gets the directories which contain the source java files
	 * @return list of project source directories
	 * @throws Exception if the path is not proper, or the project is not<br/>
	 * created by eclipse (<code>.classpath</code> file is missing)
	 */
	String[]getSourceDirectories()throws JProbeException;
	/**
	 * adds a <code>lib</code> folder to the project
	 * @throws IOException if the project path is incorrect, or writing to the
	 * file system is not possible.
	 */
	void addLibraryFolder() throws IOException;
	/**
	 * adds <code>emma.jar, emma_ant.jar, junit.jar</code> libraries to the
	 * project <code>lib</code> folder
	 * @throws IOException if the project path is incorrect, or writing to the
	 * file system is not possible.
	 */
	void copyTestingLibraries() throws IOException;
	/**
	 * creates <code>runtests.xml</code> file in the base directory of the project
	 * @throws IOException if the project path is incorrect, or writing to the
	 * file system is not possible.
	 */
	void createTestingANTScript() throws IOException;
	/**
	 * runs the generated tests and any other existing test cases in the project,
	 * and initialize the coverage and test results
	 * @return true if the build was successful, false otherwise
	 */
	boolean runTests();
	/**
	 * gets the coverage results
	 */
	C getCoverageResult();
	/**
	 * gets the test results
	 */
	T getJUnitResults();
	/**
	 * gets the project name
	 */
	String getProject();
	/**
	 * creates unit test cases,<br/>
	 * 1. create jprobe directory<br/>
	 * 2. create packages as they are in the source directory<br/>
	 * 3. for each package, get every class and generate test cases<br/>
	 * @throws IOException,JProbeException if the filesystem denied the process of writing to
	 * the project directory
	 */
	void createUnitTestCases() throws IOException,JProbeException;
	/**
	 * gets the current process execution progress
	 * @return the progress of the current running task
	 */
	int getProgress();
	/**
	 * gets all the packages of the project
	 * @return list of packages
	 * @throws Exception if the project directory does not exist or the project is not proper java project
	 */
	String[]getPackages() throws JProbeException;
	/**
	 * compiles the first listed source directory in the list of sources
	 * @throws IOException if the path to the project is incorrect
	 */
	void compile() throws IOException;
	/**
	 * compiles a specific source directory
	 * @param sourceDirectory
	 * @throws InterruptedException
	 * @throws Exception
	 */
	void compile(String sourceDirectory) throws IOException;
	/**
	 * sets the current project
	 * @param currentProject the project for which the operations are done
	 * @throws JProbeRuntimeException if the selected project is invalid
	 */
	void setProject(String currentProject);
}
